def _print_line(char: str, char_count: int, white_spaces_count: int):
    assert len(char) == 1
    assert char_count > 0
    assert white_spaces_count >= 0

    white_space = " "
    print(f"{white_space * white_spaces_count}{char * char_count}")


def _print_graph_a(lines_count: int,
                   starting_char: str = "a",
                   reverse: bool = False,
                   additional_white_space_count: int = 0) -> str:
    assert lines_count > 0
    assert len(starting_char) == 1

    if reverse:
        def get_factors(line):
            return lines_count - line_index - 1, line_index
    else:
        def get_factors(line):
            return line_index, lines_count - line_index - 1

    char = None
    starting_char_ord = ord(starting_char)
    for line_index in range(lines_count):
        char = chr(starting_char_ord + line_index)
        factors = get_factors(line_index)
        _print_line(char, factors[0] * 2 + 1,
                    factors[1] + additional_white_space_count)
    return char


def _print_graph_b(lines_count: int):
    assert lines_count > 0 and lines_count % 2 == 1

    lines_count //= 2
    char = _print_graph_a(lines_count + 1, starting_char="A")

    assert len(char) == 1
    char = chr(ord(char) + 1)
    _print_graph_a(lines_count, starting_char=char, reverse=True, additional_white_space_count=1)


def _main():
    import random

    n = random.randint(5, 10)
    print(f"a({n})：")
    _print_graph_a(n)

    n = random.randrange(5, 10, 2)
    print(f"b({n})：")
    _print_graph_b(n)


if __name__ == "__main__":
    _main()
